@extends('layout.master')

@section('title','商户提现列表')

@section('css')
    @parent
    <!-- Daterange picker plugins css -->
    <link href="{{ asset('plugins/bower_components/bootstrap-daterangepicker/daterangepicker.css') }}" rel="stylesheet">
    <style>
        .floating-labels .radioInput label {
            position: static;
        }

    </style>
@endsection
@section('main')

    <div class="modal fade" id="refuse" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel1">拒绝提现</h4>
                </div>
                <div class="modal-body">
                    <form class="floating-labels role-edit">
                        <input id="id-edit-refuse" name="id" type="hidden" value="">
                        <fieldset style="border:0;">
                            <div class="form-group m-b-40 m-t-10">
                                <input type="text" class="form-control" id="refuse-content" name="refuse_content"
                                       required><span
                                        class="highlight"></span> <span class="bar"></span>
                                <label for="input1">拒绝理由</label>
                            </div>
                            <div class="form-actions">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="row">
                                            <div class="col-md-offset-3 col-md-9">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                                </button>
                                                {!! csrf_field() !!}
                                                <button type="submit" class="btn btn-success" id="btn-refuse"><i
                                                            class="fa fa-check"></i> 保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="panel">
        <div class="panel-wrapper collapse in" aria-expanded="true">
            <div class="panel-body">
                <form action="#">
                    <div class="form-body">
                        <div class="row">
                            <div class="col-md-3 col-sm-6">
                                <div class="form-group">
                                    <label class="control-label">订单号</label>
                                    <input type="text" class="column_filter form-control"
                                           data-column="0"
                                           placeholder="订单号">
                                </div>
                            </div>
                            <div class="col-xs-3 col-md-3">
                                <div class="form-group">
                                    <label for="status">状态</label>
                                    <select class="form-control column_filter"
                                            data-column="1">
                                        <option value="a">全部</option>
                                        @foreach(App\JkblShanghuWithdraw::$StatusDisplay as $key => $value)
                                            <option value="{{ $key }}">{{ $value }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="white-box">
            <div class="table-responsive">
                <table id="example23"
                       class="display nowrap table table-striped table-bordered table-hover order-column my-table "
                       cellspacing="0" width="100%" data-url="{{ url(request()->getUri()) }}">
                    <thead>
                    <tr>
                        <th>订单号</th>
                        <th>商户名称</th>
                        <th>支付宝账号</th>
                        <th>提现金额</th>
                        <th>审核状态</th>
                        <th>申请时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection

@section('js')
    @parent
    <script src="{{ asset('js/myself.js') }}"></script>
    <script>
        //通过
        obj.on('click', '.btn-done', function () {
            var id = $(this).data('id');
            var _this = $(this);
            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: '/shop/withdraw/done/' + id,
                        type: 'POST',
                        success: function (data) {
                            if (data.status !== 1) {
                                swal(data.message);
                            } else {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            }
                        }
                    })
                }
            );
        });

        //不通过
        $("#btn-refuse").click(function (e) {
            e.preventDefault();
            var id = $("#id-edit-refuse").val();
            var refuse_content = $("#refuse-content").val();
            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: '/shop/withdraw/no/' + id,
                        data: {refuse_content: refuse_content},
                        type: 'POST',
                        success: function (data) {
                            if (data.status !== 1) {
                                swal(data.message);
                            } else {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            }
                        }
                    })
                }
            );
        });

        function refuse(sid) {
            $("#id-edit-refuse").val(sid);
        }

    </script>
@endsection